package com.april.pattern.behavioral.interpreter;

/**
 * @author April
 * @version V1.0.0
 * @date 2019/07/09 10:03
 * @description
 */
public class OperatorUtil {
    public static boolean isOperator(String symbol) {
        return ("+".equals(symbol) || "*".equals(symbol));

    }


    public static Interpreter getExpressionObject(Interpreter firstExpression, Interpreter secondExpression,
                                                  String symbol) {
        if ("+".equals(symbol)) {
            return new AddInterpreter(firstExpression, secondExpression);
        } else if ("*".equals(symbol)) {
            return new MultiInterpreter(firstExpression, secondExpression);
        }
        return null;
    }
}
